package com.ucomm.talent.adapter;

import java.util.ArrayList;

import com.ucomm.talent.AppConfig;
import com.ucomm.talent.R;
import com.ucomm.talent.model.TalentsInfo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class TalentsInfoListAdapter extends BaseAdapter{
	private LayoutInflater mInflater;
	private ArrayList<TalentsInfo> mData;
	
	public TalentsInfoListAdapter(Context context,ArrayList<TalentsInfo> mData) {
		this.mInflater = LayoutInflater.from(context);
		this.mData = mData;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return mData.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return mData.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		ViewHolder holder = null;
	        if (convertView == null) {

	            holder=new ViewHolder();

	            convertView = mInflater.inflate(R.layout.talents_item_layout, null);
	            holder.name = (TextView) convertView.findViewById(R.id.name);
	            holder.resume_id = (TextView)convertView.findViewById(R.id.resume_id);
	            holder.job_post = (TextView)convertView.findViewById(R.id.job_post);
	            holder.salary = (TextView) convertView.findViewById(R.id.salary);
	            convertView.setTag(holder);

	        }else {
	            holder = (ViewHolder)convertView.getTag();
	        }
	        TalentsInfo info = mData.get(position);
	        String job_post = null;
	        String salary = null;
	        holder.name.setText(info.getName());
	        holder.resume_id.setText(info.getResumeId()+"");
	        if(AppConfig.jobMap.size() !=0 && AppConfig.userMap.size() !=0 ){
	        	job_post = AppConfig.jobMap.get(info.getJobName());
	        	salary = AppConfig.userMap.get(info.getSalary()+"");
	        	
	        }
	        holder.job_post.setText(job_post);
	        holder.salary.setText(salary);

	        return convertView;
	}
	final class ViewHolder{
		public TextView name;
		public TextView resume_id;
		public TextView job_post;
		public TextView salary;
	}
	public ArrayList<TalentsInfo> getmData() {
		// TODO Auto-generated method stub
		return mData;
	}

}
